<?php /* Smarty version 2.6.26, created on 2015-08-23 15:51:03
         compiled from ask.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'default', 'ask.html', 52, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>后盾问答</title>
	<meta name="keywords" content="后盾问答"/>
	<meta name="description" content="后盾问答"/>
	<link rel="stylesheet" href="Public/Home/Css/ask.css" />
	<script type="text/javascript" src='Public/Home/Js/jquery-1.7.2.min.js'></script>
	<script type="text/javascript">
		$(function(){
			//点击select表单的时候
			$('select[name=cate-one]').change(function(){
				//获得每一次点击分类的cid
				var cid = $(this).val();
				//设置cid表单的值，未来就可以用它来判断是否选择了分类
				$('input[name=cid]').val(cid);
				//如果点击到第三个就不需要发异步了
				var index = $(this).index();
				if(index>2) return;
				//获取下一个select元素
				var nextSelect = $(this).next();
				//下一个的下一个，也就是第三个消失
				nextSelect.next().hide();
				//发送异步
				$.ajax({
					type:"post",
					url:"./index.php?c=Ask&a=getSon",
					data:{id:cid},
					//php返回的数据类型
					dataType:'json',
					//phpData就是每次点击分类的时候的子集
					success:function(phpData){
						var option = '';
						//循环json,k,v就是foreach里面的$k,$v一样
						$.each(phpData, function(k,v) {    
							 option += '<option value="'+v.cid+'">'+v.title+'</option>';                                                      
						});
						//让下一个select表单显示并且给它插入option
						nextSelect.show().html(option);
					}
				});
			})
			
			//点击“确定”之后关闭窗口
			$('#ok').click(function(){
				//因为close-window单击之后会关闭窗口
				//所以点击“确定”触发close-window单击事件就可以了
				$('.close-window').click();
			})
			//是否登陆
			var isLogin = <?php echo ((is_array($_tmp=@$_SESSION['uid'])) ? $this->_run_mod_handler('default', true, $_tmp, 0) : smarty_modifier_default($_tmp, 0)); ?>
;
			//在提交问题的时候
			$('#askForm').submit(function(){
				//如果没有登陆
				if(!isLogin){
					//就相当于点击了class为login这个元素
					$('.login').click();
					//不让提交
					return false;
				}
				//如果没有选择分类
				var hiddenCid = $('input[name=cid]').val();
				if(hiddenCid == '0'){
					$('.cate-btn').click();
					return false;
				}
				
				//最后就可以提交
				return true;
			})
		})
	</script>
	<!-- top -->
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "../Common/header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<!-- top结束 -->
	<div id='location'>
		<a href="">后盾问答</a>&nbsp;>&nbsp;提问
	</div>

<!--------------------中部-------------------->
	<div id='center'>
		<div class='send'>
			<div class='title'>
				<p class='left'>向亿万网友们提问</p>
				<p class='right'>您还可以输入<span id='num'>50</span>个字</p>
			</div>
			<form action="" method='post' id="askForm">
				<div class='cons'>
					<textarea name="content"></textarea>
				</div>
				<div class='reward'>
					<span id='sel-cate' class='cate-btn'>选择分类</span>
					<ul>
						<li>
							我的金币：<span>20</span>
						</li>
						<li>
					  悬赏：<select name="reward">
								<option value="0">0</option>
								<option value="5">5</option>
								<option value="10">10</option>
								<option value="15">15</option>
								<option value="20">20</option>
								<option value="30">30</option>
								<option value="50">50</option>
								<option value="80">80</option>
								<option value="100">100</option>
							</select>金币
						</li>
					</ul>
				</div>
				<input type='hidden' name='cid' value='0'/>
				<input type="submit" value='提交问题' class='send-btn'/>
			</form>
		</div>
	</div>
	<div id='category'>
		<p class='title'>
			<span>请选择分类</span>
			<a href="" class='close-window'></a>
		</p>
		<div class='sel'>
			<p>为您的问题选择一个合适的分类：</p>
			<select name="cate-one" size='16'>
				<?php $_from = $this->_tpl_vars['topCate']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['v']):
?>
					<option value="<?php echo $this->_tpl_vars['v']['cid']; ?>
"><?php echo $this->_tpl_vars['v']['title']; ?>
</option>
				<?php endforeach; endif; unset($_from); ?>
			</select>
			<select name="cate-one" size='16' class='hidden'></select>
			<select name="cate-one" size='16' class='hidden'></select>
		</div>
		<p class='bottom'>
			<span id='ok'>确定</span>
		</p>
	</div>
<!--------------------中部结束-------------------->

<!-- 底部 -->

		<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "./../common/footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>